#ifndef BASESETTINGPAGE_H
#define BASESETTINGPAGE_H

#include <QWidget>
#include <QHash>
#include <QThread>
#include "../remoteservice/configinfo.h"

namespace Ui {
class BaseSettingPage;
}

class BasePageWorker;

class BaseSettingPage : public QWidget
{
    Q_OBJECT
    
public:
    explicit BaseSettingPage(QWidget *parent = 0);
    ~BaseSettingPage();

    bool isIndex();

signals:
    void updateStatus(int);

protected:
    bool eventFilter(QObject *o, QEvent *e);
    void showEvent(QShowEvent *e);

private slots:
    void dealPlatform(QString value);
    void dealRunServer(QString value);
    void updateConfig(QString key, QString value);

    void outputModeChanged(int);
    void showLocalChanged(int);
    void inputChanged(int);
    void inputVolChanged(int);
    void outputVolChanged(int);
    void platformChanged(int);
    void runserverChanged(int);
    void lineEditChanged(QString);
    void showKeyBoard();

    void configSlot(ConfigInfo);
    void modifyConfigResponseSlot(BaseResp);
    void resgisterResponseSlot(BaseResp);

    void on_pushButton_clicked();

private:
    void initOutPut();
    void initVoiceSetting();
    void initRegisterSetting();
    void initFocusOrder();
    void setItemIndex(QString name, int index);
    void setItemVol(QString name, int vol);
    void setItemText(QString name, QString txt);

    void changeVedioOption();
    void changeDocOption();
    
private:
    Ui::BaseSettingPage *ui;
    QHash<QObject*, QList<QObject*> > m_ctrlOrder;
    QList<QObject *> m_platHideList;
    QList<QObject *> m_runserverHideList;
    QList<QObject *> m_svcIpHideList;
    QList<QObject *> m_svcPortHideList;
    QList<QString> m_vedioMode;int m_vmIndex;
    QList<QString> m_docMode; int m_dmIndex;

    QHash<int,QString> m_vedioIndexMap;
    QHash<int,QString> m_docIndexMap;
    QHash<int, QString> m_indexStr;

    BasePageWorker *worker;
    QThread workThread;
    int m_inputvol;
    int m_outputvol;
};

#endif // BASESETTINGPAGE_H
